package com.hs.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Bai Dingkun
 * @date 2022-05-07
 * @desc
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultBean {
    private Integer code;
    private String msg;
    private Object data;

    /**
     * 操作成功
     * @return
     */
    public static ResultBean OK(){
        ResultBean resultBean = new ResultBean();
        resultBean.setCode(Constants.SUCCESS_CODE);
        resultBean.setMsg("success!");
        return resultBean;
    }

    public static ResultBean OK(String msg){
        ResultBean resultBean = new ResultBean();
        resultBean.setCode(Constants.SUCCESS_CODE);
        resultBean.setMsg(msg);
        return resultBean;
    }
    /**
     * 操作失败
     * @return
     */
    public static ResultBean ERROR(){
        ResultBean resultBean = new ResultBean();
        resultBean.setCode(Constants.ERROR_CODE);
        resultBean.setMsg("failed!");
        return resultBean;
    }

    public static ResultBean ERROR(String msg){
        ResultBean resultBean = new ResultBean();
        resultBean.setCode(Constants.ERROR_CODE);
        resultBean.setMsg(msg);
        return resultBean;
    }
}
